﻿-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date, ,>
-- Description:	<Description, ,>
-- =============================================
CREATE FUNCTION ISDATEINRANGE 
(
	@StartDate datetime=NULL,
	@EndDate datetime=NULL,
	@EvalDate datetime=NULL
)
RETURNS bit
AS
BEGIN
	IF @EvalDate IS NULL BEGIN
		SET @EvalDate = GetDate()
	END
	DECLARE @ISINRANGE bit
	SET @ISINRANGE = 0

	IF (@StartDate IS NULL OR @EvalDate >= @StartDate) AND (@EndDate IS NULL OR @EvalDate <= @EndDate) BEGIN
		SET @ISINRANGE = 1
	END

	RETURN @ISINRANGE

END
